<?php


/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Story
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
?>
<?php if(!$this->showdescription) { ?>
	<?php if ($this->paginator->getTotalItemCount()): ?>

	  <?php $this->headScript()->appendFile('application/modules/Story/externals/scripts/slideshow.js') ?>
	  <style>
	.layout_bottom .layout_middle{width:100%;}
	.story_featured_mask {width: 100%;height: 190px;}
	.story_featured_slide{
		border: 1px solid #DDDDDD;
		border-radius: 5px 5px 5px 5px;
		float: left;
		height: 173px;
		margin-right: 32px;
	 }
	 .story_featured_slide_parent > div:last-child{margin-right:0px;}
	div.story_featured_slide .story_photo {
		float: none;
		height: 111px;
		margin-left: 0;
		overflow: hidden;
		width: 100%;
	}
	div.story_featured_slide .story_photo img {
			border: medium none;
			min-height: 100%;
			min-width: 100%;
		}
	div.story_featured_slide .story_title {
		font-size: 11px;
		font-weight: bold;
		margin: 4px;
	}
	div.story_featured_slide .story_meta {
		border-top: 1px solid #DDDDDD;
		color: #999999;
		margin: 0;
		padding: 0 5px;
		height: 35px;
	}
	.story_featured_mask .story_featured_slides > div{
		height: 175px;
		margin: 10px 0;
		padding: 0;
	}
	</style>
	  <div class="story_featured_stories">
		<div class="story_featured_mask">
		  <div id="<?php echo $this->widget_name?>" class="story_featured_slides" style="width:100%">
			<?php 
				$story_array = array(); 
				$i=0; $g=-1;
				$column = empty($this->viewer)?5:4;
				foreach ($this->paginator as $story){ 
					if($i%$column==0) $g++; 
					$story_array[$g][] = $story;
					$i++;
				} ?>
			<?php foreach ($story_array as $stories): ?>
			  <div class="story_featured_slide_parent">
			  <?php foreach ($stories as $story): ?>
			  <div class="story_featured_slide story_record_<?php echo $story->getIdentity();?>">
				  <div class="story_photo">
					<?php echo $this->htmlLink($story->getHref(), $this->itemPhoto($story, 'thumb.normal'));?>
				  </div>   
				<div class="story_content">
				  <div class="story_title">
					<?php echo $this->partial('index/_title.tpl', 'story', array('story' => $story, 'max_title_length' => 42))?>
				  </div> 
				  <?php if ($this->showmeta): ?>
					<div class="story_meta">
					  <?php echo $this->partial('index/_meta.tpl', 'story', array('story' => $story, 'display_style'=> 'narrow'))?>
					</div>
				  <?php endif; ?>
				</div>
			  </div>  
			  <?php endforeach; ?>  
			  </div>
			<?php endforeach; ?>  
		  </div>
		</div>
		<?php if ($this->use_slideshow): ?>
		  <p class="story_featured_slideshow_buttons" id="<?php echo $this->widget_name?>_buttons">
			<span id="<?php echo $this->widget_name?>_prev" class="story_slideshow_button_prev"><span><?php echo $this->translate('&lt;&lt; Previous'); ?></span></span>
			<span id="<?php echo $this->widget_name?>_play" class="story_slideshow_button_play"><span><?php echo $this->translate('Play &gt;'); ?></span></span>
			<span id="<?php echo $this->widget_name?>_stop" class="story_slideshow_button_stop"><span><?php echo $this->translate('Stop'); ?></span></span>
			<span id="<?php echo $this->widget_name?>_next" class="story_slideshow_button_next"><span><?php echo $this->translate('Next &gt;&gt;'); ?></span></span>
		  </p>
		<?php endif; ?>
	  </div>
	  <?php if ($this->use_slideshow): ?>
		<script type="text/javascript">
		en4.core.runonce.add(function(){
		  var <?php echo $this->widget_name?>_width = $('<?php echo $this->widget_name?>').getSize().x;
		  $$('#<?php echo $this->widget_name?> div.story_featured_slide_parent').each(function(el){
			el.setStyle('width', <?php echo $this->widget_name?>_width - 10);
		  });
		  $$('#<?php echo $this->widget_name?> div.story_featured_slide').each(function(el){
			el.setStyle('width', <?php echo $this->widget_name?>_width / <?php echo empty($this->viewer)?5:4 ?> - 30);
		  });
			var <?php echo $this->widget_name?> = new radcodesStoryNoobSlide({
				box: $('<?php echo $this->widget_name?>'),
				items: $$('#<?php echo $this->widget_name?> div.story_featured_slide_parent'),
				size: <?php echo $this->widget_name?>_width,
				autoPlay: true,
				interval: 8000,
				addButtons: {
					previous: $('<?php echo $this->widget_name?>_prev'),
					play: $('<?php echo $this->widget_name?>_play'),
					stop: $('<?php echo $this->widget_name?>_stop'),
					next: $('<?php echo $this->widget_name?>_next')
				},
				onWalk: function(currentItem,currentHandle){
				}
			});
		});
		</script>
	  <?php endif; ?>

	<?php else: ?>
	  <div class="tip">
		<span>
		  <?php echo $this->translate('There are no featured stories.');?>
		</span>
	  </div>
	<?php endif; ?>
<?php } else { ?>
	<style>
	  .layout_bottom .layout_middle{width:100%;}
	  .story_featured_mask {width: 100%;}
	 </style>
	<?php if ($this->paginator->getTotalItemCount()): ?>

	  <?php $this->headScript()->appendFile('application/modules/Story/externals/scripts/slideshow.js') ?>
	  
	  <div class="story_featured_stories">
		<div class="story_featured_mask">
		  <div id="<?php echo $this->widget_name?>" class="story_featured_slides">
			<?php foreach ($this->paginator as $story): ?>
			  <div class="story_featured_slide story_record_<?php echo $story->getIdentity();?>">
				  <div class="story_photo">
					<?php echo $this->htmlLink($story->getHref(), $this->itemPhoto($story, 'thumb.normal'));?>
				  </div>       
				<div class="story_content">
				  <div class="story_title">
					<?php echo $this->partial('index/_title.tpl', 'story', array('story' => $story, 'max_title_length' => 42))?>
				  </div>
				  <?php if ($this->showdescription && $story->getDescription()): ?>
					<div class="story_description">
					  <?php echo $this->radcodes()->text()->truncate($story->getDescription(), 255); ?>
					  <?php //echo $this->partial('index/_description.tpl', 'story', array('story' => $story))?>
					</div>
				  <?php endif; ?>  
				  <?php if ($this->showmeta): ?>
					<div class="story_meta">
					  <?php echo $this->partial('index/_meta.tpl', 'story', array('story' => $story))?>
					</div>
				  <?php endif; ?>
				</div>
			  </div>  
			<?php endforeach; ?>  
		  </div>
		</div>
		<?php if ($this->use_slideshow): ?>
		  <p class="story_featured_slideshow_buttons" id="<?php echo $this->widget_name?>_buttons">
			<span id="<?php echo $this->widget_name?>_prev" class="story_slideshow_button_prev"><span><?php echo $this->translate('&lt;&lt; Previous'); ?></span></span>
			<span id="<?php echo $this->widget_name?>_play" class="story_slideshow_button_play"><span><?php echo $this->translate('Play &gt;'); ?></span></span>
			<span id="<?php echo $this->widget_name?>_stop" class="story_slideshow_button_stop"><span><?php echo $this->translate('Stop'); ?></span></span>
			<span id="<?php echo $this->widget_name?>_next" class="story_slideshow_button_next"><span><?php echo $this->translate('Next &gt;&gt;'); ?></span></span>
		  </p>
		<?php endif; ?>
	  </div>
	  <?php if ($this->use_slideshow): ?>
		<script type="text/javascript">
		en4.core.runonce.add(function(){
		  var <?php echo $this->widget_name?>_width = $('<?php echo $this->widget_name?>').getSize().x;
		  
		  $$('#<?php echo $this->widget_name?> div.story_featured_slide').each(function(el){
			el.setStyle('width', <?php echo $this->widget_name?>_width - 30);
		  });
			var <?php echo $this->widget_name?> = new radcodesStoryNoobSlide({
				box: $('<?php echo $this->widget_name?>'),
				items: $$('#<?php echo $this->widget_name?> div.story_featured_slide'),
				size: <?php echo $this->widget_name?>_width,
				autoPlay: true,
				interval: 8000,
				addButtons: {
					previous: $('<?php echo $this->widget_name?>_prev'),
					play: $('<?php echo $this->widget_name?>_play'),
					stop: $('<?php echo $this->widget_name?>_stop'),
					next: $('<?php echo $this->widget_name?>_next')
				},
				onWalk: function(currentItem,currentHandle){
				}
			});
		});
		</script>
	  <?php endif; ?>

	<?php else: ?>
	  <div class="tip">
		<span>
		  <?php echo $this->translate('There are no featured stories.');?>
		</span>
	  </div>
	<?php endif; ?>
<?php } ?>